var URL_all = 'http://hsmy.vrdete.com/'; //接口地址
var IMGUrl = 'http://p2816srbo.bkt.clouddn.com/'; // 图片前缀地址
var COMPANY_TITLE = "华胜集团"; //title
var ScriptList = [
	"js/mui.min.js",
	"js/jquery-3.2.1.min.js",
	"js/Fn.js"
];

document.title = '华胜集团';

//<script>document.write("<script type='text/javascript' src='js/Fn.js?v=" + Date.now() + "'><\/script>");document.write("<script type='text/javascript' src='js/Nindex.js?v=" + Date.now() + "'><\/script>");</script> //调用script添加时间戳

	//获取用户信息并绑定事件


//用户信息API
var user = (function() {
	var userConfig = {};
	return {
		setter: function(config, need_keys) { //info:setting config form user. [object,array]
			var isNeedKey = need_keys.length > 0;
			//mixin
			for(var key in config) {
				// isHas currentKey
				if(isNeedKey) { //isHas need_keys
					if(need_keys.indexOf(key) >= 0)
						userConfig[key] = config[key];
				} else {
					userConfig[key] = config[key];
				}
			};
			//return allData
			return this.getter();
		},
		getter: function() {
			return userConfig;
		},
		getterFormNet: function(need_keys, callback) { //get ajax info
			var _this = this;
			MuiAjaxFn("client/userinfo/selectbyinfo", {}, function(data) {
				_this.setter(data.dataResultList[0], need_keys);
				callback && callback(_this.getter());
			})
		}
	
	};
})();


	
	user.getterFormNet([], function(data) {
//		event();
	})


function loadJs() {
	//加载所有共有JS资源文件
	for(index in ScriptList) {
		var oHead = document.getElementsByTagName('body')[0];
		var oScript = document.createElement("script");
		oScript.type = "text/javascript";
		oScript.src = ScriptList[index];
		oHead.appendChild(oScript);
	}
}

function OpenNewWindow(url, id, styles, extras, show) {
	//打开新的页面 
	mui.openWindow({
		url: url,
		id: id,
		styles: styles,
		extras: extras,
		createNew: false, //是否重复创建同样id的webview，默认为false:不重复创建，直接显示
		show: show
			//	    {
			//	      autoShow:true,//页面loaded事件发生后自动显示，默认为true
			//	      aniShow:animationType,//页面显示动画，默认为”slide-in-right“；
			//	      duration:animationTime//页面动画持续时间，Android平台默认100毫秒，iOS平台默认200毫秒；
			//	    }
			// waiting:{
			//   autoShow:true,//自动显示等待框，默认为true
			//   title:'正在加载...',//等待对话框上显示的提示内容
			//   options:{
			//     width:waiting-dialog-widht,//等待框背景区域宽度，默认根据内容自动计算合适宽度
			//     height:waiting-dialog-height,//等待框背景区域高度，默认根据内容自动计算合适高度
			//     ......
			//   }
			// }
	})
}

//表单序列化转换成json格式
//$('.regist-from').serializeJson() //调用方式
(function($) {
	$.fn.serializeJson = function() {
		var serializeObj = {};
		var array = this.serializeArray();
		var str = this.serialize();
		$(array).each(function() {
			if(serializeObj[this.name]) {
				if($.isArray(serializeObj[this.name])) {
					serializeObj[this.name].push(this.value);
				} else {
					serializeObj[this.name] = [serializeObj[this.name], this.value];
				}
			} else {
				serializeObj[this.name] = this.value;
			}
		});
		return serializeObj;
	};
})(jQuery);

$(function() {
	//	城市
	$(".nowCityhref").on("tap", function() {
			OpenNewWindow("location.html", "location.html", {}, {}, {});
		})
		//	消息
	$(".noticehref").on("tap", function() {
			OpenNewWindow("notice.html", "notice.html", {}, {}, {});
		})
		//	
		//	搜索
	$(".serchhref").on("tap", function() {
		OpenNewWindow("search.html", "search.html", {}, {}, {});
	})
	$(".evaluationListHref").on("tap", function() {
		OpenNewWindow("evaluationList.html", "evaluationList.html", {}, {}, {});
	})

	////	产品列表有分类
	//	
	////	产品列表无分类
	//	$(".searchpage2Href").on("tap",function(){
	//		OpenNewWindow("search-page2.html","search-page2.html",{},{},{});
	//	})
	//
	////	banner点击资讯
	//	$(".bannerHref > div").on("tap",function(){
	//		OpenNewWindow("banner-page.html","banner-page.html",{},{},{});
	//	})
	//	
	////	单个商品详情
	//	$(".ProductDetailHref").on("tap",function(){
	//		OpenNewWindow("ProductDetail.html","ProductDetail.html",{},{},{});
	//	})
	//	购物车列表
	$(".cartHref").on("tap", function() {
			OpenNewWindow("tab-Main.html?tabType=2", "tab-cart.html", {}, {}, {});
		})
		////	订单列表
		//	$(".orderHref").on("tap",function(){
		//		OpenNewWindow("Order.html","Order.html",{},{},{});
		//	})	
		//	
		//	
		////	订单确定
		//	// $(".orderConfirmHref").on("tap",function(){
		//	// 	OpenNewWindow("order_confirm.html","order_confirm.html",{},{},{});
		//	// })	
		////	订单确定2
		//	$(".orderConfirm2Href").on("tap",function(){
		//		OpenNewWindow("order_confirm2.html","order_confirm2.html",{},{},{});
		//	})	
		//	
		//	
		////	地址列表
	$(".addressListHref").on("tap", function() {
		localStorage.orderMsg = ''; //每次从个人页面进入地址页面.需要去掉订单页面的选中地址选项
		OpenNewWindow("addressList.html", "addressList.html", {}, {}, {});
	})

	//	设置
	$(".setUpHref").on("tap", function() {
			OpenNewWindow("setUp.html", "setUp.html", {}, {}, {});
		})
		//	个人资料
	$(".personalHref").on("tap", function() {
			OpenNewWindow("personal.html", "personal.html", {}, {}, {});
		})
		//	收藏
	$(".collectionListHref").on("tap", function() {
			OpenNewWindow("collectionList.html", "collectionList.html", {}, {}, {});
		})
		//	我的关注
	$(".followListHref").on("tap", function() {
			OpenNewWindow("follow.html", "follow.html", {}, {}, {});
		})
		//	关注公众号
	$(".followWeixinHref").on("tap", function() {
			OpenNewWindow("follow_weixin.html", "follow_weixin.html", {}, {}, {});
		})
		//	浏览历史
	$(".browseHistoryHref").on("tap", function() {
			OpenNewWindow("browseHistory.html", "browseHistory.html", {}, {}, {});
		})
		//	邀请
	$(".InvitationHref").on("tap", function() {
		OpenNewWindow("Invitation.html", "Invitation.html", {}, {}, {});
	})

	//	帮助中心
	$(".HelpCenterHref").on("tap", function() {
			OpenNewWindow("HelpCenter.html?source=help", "HelpCenter.html", {}, {}, {});
		})
		//	业务代表
	$(".BusinessRepresentativeHref").on("tap", function() {
			OpenNewWindow("BusinessRepresentative.html", "BusinessRepresentative.html", {}, {}, {});
		})
		//	业务代表
	$(".BusinessRepresentative2Href").on("tap", function() {
		OpenNewWindow("BusinessRepresentative2.html", "BusinessRepresentative2.html", {}, {}, {});
	})

	$(".locationHref").on("tap", function() {
		OpenNewWindow("location.html", "location.html", {}, {}, {});
	})

})

function GetQueryString(name) {
	//	处理地址栏的参数
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	var r = window.location.search.substr(1).match(reg);
	if(r != null) return decodeURI(r[2]);
	return null;
}

function getUrlParam(key) {
	// 获取参数
	var url = window.location.search;
	// 正则筛选地址栏
	var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)");
	// 匹配目标参数
	var result = url.substr(1).match(reg);
	//返回参数值
	return result ? decodeURIComponent(result[2]) : null;
}

function getMoth(str) {
	var oDate = new Date(str),
		oMonth = oDate.getMonth() + 1,
		oDay = oDate.getDate(),
		oTime = getzf(oMonth) + '-' + getzf(oDay); //最后拼接时间  
	return oTime;
};
//console.log(getMoth(1465959000));//使用方法  

//获得年月日      得到日期oTime  
function getMyDate(str) {
	var oDate = new Date(str),
		oYear = oDate.getFullYear(),
		oMonth = oDate.getMonth() + 1,
		oDay = oDate.getDate(),
		oHour = oDate.getHours(),
		oMin = oDate.getMinutes(),
		oSen = oDate.getSeconds(),
		oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + ' ' + getzf(oHour) + ':' + getzf(oMin) + ':' + getzf(oSen); //最后拼接时间  
	return oTime;
};
//补0操作  
function getzf(num) {
	if(parseInt(num) < 10) {
		num = '0' + num;
	}
	return num;
}

function GetNumFn(num1, price) {
	//数量与价钱相乘. 价钱已提升了100倍.调用之后请除去100. (此处为了处理浮点型相乘的精度问题)
	num1 = parseInt(num1.substring(1));
	price = parseFloat(price.substring(1)).toFixed(2) * 100;
	console.log(num1, price);
	return(num1 * price)
}

function previewImg(input, obj) {
	//上传图片预览
	if(input.files && input.files[0]) {
		var reader = new FileReader(),
			img = new Image();
		reader.onload = function(e) {
			if(input.files[0].length > 307200) { //图片大于300kb则压缩
				img.src = e.target.result;
				img.onload = function() {
					$(obj).attr('src', compress(img));
				}
			} else {
				$(obj).attr('src', e.target.result);
			}
		}
		reader.readAsDataURL(input.files[0]);
		return 1;
	}
}

function objcssFn(allobj, objcss, obj) {
	//处理css
	$(allobj).not($(allobj).eq(obj).addClass(objcss)).removeClass(objcss);
}

function objshowFn(allobj, obj) {
	//	处理显示隐藏
	$(allobj).not($(allobj).eq(obj).show()).hide();
}

function addminuFn() {
	//	加减按钮的函数
	//加的效果
	$(".icon-jia").click(function() {
		var n = $(this).prev().val();
		var num = parseInt(n) + 1;
		if(num == 0) {
			return;
		}
		$(this).prev().val(num);
	});
	//减的效果
	$(".icon-jian").click(function() {
		var n = $(this).next().val();
		var num = parseInt(n) - 1;
		if(num == 0) {
			return;
		}
		$(this).next().val(num);
	});
	$('#needNumber').change(function() {
		//		$(this).val()
	})
}

function nodata(txt, obj, youlike, sheight) {
	//提示无数据页面
	var nodatastr = '<div class="nodata"><img src="img/logo.JPG" /><p>' + txt + '</p></div>';

	if(youlike != 0) {
		var nodatastr = '<div class="nodata"><img src="img/logo.JPG" /><p>' + txt + '</p></div><div class="title100 youlikebox"><span class="iconfont  icon-favorites"></span> 猜你喜欢</div><div class="pLikelist">	</div>';

		YouLikeFn();
	}
	$(obj).html(nodatastr);

}

var tap_first = null;

function unsafe_tap() {
	//	防止多次点击
	if(!tap_first) {
		tap_first = new Date().getTime();
		setTimeout(function() {
			tap_first = null;
		}, 1500);
	} else {
		return true;
	}
}

//通过调用购物车接口判断是否账户是正常的登录状态
//MuiAjaxFn("/client/detailed/selectbyuserId?adcode=100000&page=0&pagesize=12",'' ,function(data){
//	
//},'get');



function MuiAjaxFn(Url , jsondata , callBack , Type ,  added  ){
	if(Type){
	
	}else{
		Type='post';
		
	}
	mui.ajax(URL_all + Url, {
		data: jsondata,
		dataType: 'json', //服务器返回json格式数据
		type: Type, //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json',
			"userToken": localStorage.userToken
		},
		success: function(data) {
//			console.log(data)
			if(data.Error){
				if(data.Error.status == '203'){
					console.log("重新进行登录的选择");
					//登录账户异常
//					mui.toast(data.Error.message);
					WechatNewLogin();
				}
			}else{
				callBack(data,added)
			}

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	});
	
}

function AjaxPostFn(Url, jsondata, callBack) {
	//	需要登录的post方式调用接口
	mui.ajax(URL_all + Url, {
		data: jsondata,
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json',
			"userToken": localStorage.userToken
		},
		success: function(jsonData) {

			callBack(jsonData)

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	});
}

function AjaxNoLPostFn(Url, jsondata, callBack, fnidx) {
	//	不需要登录的post方式调用接口

	mui.ajax(URL_all + Url, {
		data: jsondata,
		dataType: 'json', //服务器返回json格式数据
		type: 'post', //HTTP请求类型
		timeout: 10000, //超时时间设置为10秒；
		headers: {
			'Content-Type': 'application/json'
		},
		success: function(jsonData) {

			if(fnidx) {
				callBack(jsonData, fnidx);
			} else {
				callBack(jsonData)
			}

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}
	}, fnidx);

}

function AjaxNoLGettFn(Url, jsondata, callBack, fnidx) {
	//	不需要登录的get方式调用接口


	mui.getJSON(URL_all + Url, jsondata, function(jsonData) {
		//获得服务器响应
			if(fnidx) {
				callBack(jsonData, fnidx);
			} else {
				callBack(jsonData)
			}
	}, fnidx);

}

function AjaxLGettFn(Url, callBack) {
	//	需要登录的get方式调用接口

	mui.ajax({
		"url": URL_all + Url,
		"type": 'GET',
		"dataType": "json",
		"headers": {
			'Content-Type': 'application/json',
			"userToken": localStorage.userToken
		},
		"success": function(data) {
			
			if(data.Error){
				if(data.Error.status == 203){
					//登录账户异常
//					mui.toast(data.Error.message);
					WechatNewLogin();
				}
			}else{
				callBack(data)
			}
	
		},
		"error": function(xhr, type, errorThrown) {
//			mui.toast(type);
		}
	});

}

// function addCar() {
// 	//加入购物车
// 	var commodityNumber = GetQueryString("commodityNumber");
// 	var price = 1;
// 	var goodsNum = 1;
// 	insertdetailed(commodityNumber, goodsNum, price, (new Date().getTime()),
// 		function(data) {
// 			console.log(data)
// 			var sta = data.htmlState.status
// 			if(sta != 200) {
// 				mui.toast('添加失败');
// 			} else {
// 				mui.toast('加入购物车成功!');
// 				AjaxPostFn(Url, jsondata, callBack) 
// 				mui.ajax({
// 					"url": "http://hsmytest.vrdete.com/client/detailed/selectbyuserId?adcode=10000&page=1&pagesize=12",
// 					"dataType": "json",
// 					"type": "get",
// 					"timeout": 10000000000,
// 					"headers": {
// 						'userToken': localStorage.userToken
// 					},
// 					"success": function(data) {
// 						console.log(localStorage.userToken);
// 						console.log(JSON.stringify(data));

// 					},
// 					"error": function(xhr, type, errorThrown) {
// 						console.log(type);
// 					}
// 				})
// 			}
// 		})
// }

function AddCollctionFn(cNum, callback) {
	//收藏
	if(localStorage.userToken == undefined) {
		WechatNewLogin();
	} else {
		AjaxPostFn('client/favorites/insertinfo', {
			'commodityNumber': cNum
		}, function(data) {
			console.log(data.htmlState.status)
			if(data.htmlState.status == 200) {
				mui.toast("收藏商品成功!");
				return true;

			} else {
				mui.toast("收藏失败!")
				return false;
			}
		})

	}
}

function YouLikeFn() {
	//	猜你喜欢
	var likeliststr = '';
	AjaxNoLPostFn('api/bizrelatives/selecthot?page=1&pagesize=13', {
		hotState: 1,
		sorting: 'original_price',
		tosort: 'desc'
	}, function(data) {
		$.each(data.pageInfo.list, function(idx, obj) {
			if(idx < 6) {
				likeliststr += '<div class="p2box-6" data-cNum="' + obj.bizCommodityForSales.commodityNumber + '"><div class="pimg" style="background-image:url(' + IMGUrl + '' + obj.bizCommodityForSales.mainPhoto + ') ;"></div><p>' + obj.bizCommodityForSales.title + '</p><input type="button" value="￥' + (obj.bizCommodityForSales.presentPrice / 100) + '" /></div>';

			}
			//				console.log(obj);

		})
		$(".pLikelist").html(likeliststr);
		$(".pLikelist .p2box-6:odd").addClass('fleft');
		$(".pLikelist .p2box-6").on("tap", function() {
			window.top.location.href = 'ProductDetail.html?commodityNumber=' + $(this).attr("data-cNum");
		})

	})
};

////登录
//window.addEventListener('load', function() {
//	var ua = navigator.userAgent.toLowerCase();
//	if(ua.match(/MicroMessenger/i) != "micromessenger") {
//		console.log("您使用的是非微信端的浏览器");
//	} else {
//		//		alert(localStorage.userToken)
//		if(localStorage.userToken == undefined) {
//			//未登录的新用户
//			WechatNewLogin();
//
//		} else {
////			mui.ajax({
////				"url": URL_all + 'client/userinfo/selectbyinfo',
////				"type": 'post',
////				"dataType": "json",
////				"headers": {
////					'Content-Type': 'application/json',
////					"userToken": localStorage.userToken
////				},
////				"success": function(data) {
////
////					if(data.Error) {
////						mui.toast(data.Error.error);
////						WechatLogin();
////					} else {
////						
////					}
////
////				},
////				"error": function(xhr, type, errorThrown) {
////					mui.toast(type);
////				}
////			});
//			//WechatLogin() 
//			//已经登录需要重新更新token
//
//		}
//		document.title = COMPANY_TITLE; //修改网页title的内容
//	}
//
//});

function WechatLogin() {
	// 旧的登录
	// 
	AjaxPostFn("api/wechat/openidata", {}, function(data) {
		if(data.htmlState.status != 200) {
			WechatNewLogin();
		} else {
			//				mui(".haedphoto")[0].src = data.dataResultObj.headimgurl;
			//
			//				mui(".username")[0].innerText = data.dataResultObj.nickName;
			console.log("登录成功");
		}
	})

}

function WechatNewLogin() {
	//新的登录
	var appid;
	var myurl = GetQueryString("code"); //001U6O851IsOzM1jQI851lNR851U6O8Y

	if(myurl != null && myurl.toString().length > 1) {
		console.log("拥有myur");

		var usercode = GetQueryString("code");
		mui.ajax({
			"url": URL_all+"api/wechat/postwcode",
			"dataType": "json",
			"type": "post",
			"data": "{'code':'" + usercode + "'}",
			"timeout": 10000,
			"headers": {
				'Content-Type': 'application/json'
			},
			"success": function(data) {
//				alert(data.status+' ' +data.htmlStat.emessage)
				if(data.htmlState.status == 200){
					localStorage.userToken = data.dataResultObj.userToken ; 
				window.location.href = URL_all + "mp/tab-Main.html?tabType=3&time=" + (new Date().getTime());
					
				}
//				localStorage.userToken = data.dataResultObj.userToken;
//				localStorage.headimgurl = data.dataResultObj.headimgurl;
//				localStorage.openId = data.dataResultObj.openId;
//				localStorage.nickName =filteremoji( data.dataResultObj.nickName);
				
				console.log(data)

//			window.location.href = URL_all + "mp/?time=" + (new Date().getTime());
				//				alert(JSON.stringify(data));
			},
			"error": function(xhr, type, errorThrown) {
				//异常处理；
				console.log(type);
			}
		})
	} else {
		console.log("需要重新点击登录");
		var tourl = window.location.href;
		mui.ajax({
			"url": URL_all+"api/wechat/authorize",
			"dataType": "json",
			"type": "post",
			"timeout": 10000,
			headers: {
				'Content-Type': 'application/json'
			},
			"success": function(data) {
				appid = data.dataResultObj.AppId;
				localStorage.appId = data.dataResultObj.AppId;
				//				alert(JSON.stringify(data));
				window.top.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid + '&redirect_uri=' + tourl + '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect';
			},
			"error": function(xhr, type, errorThrown) {
				//异常处理；
				console.log(type);
			}
		})
	}
}

function submitOrderInfoClick(callback) {
	var exist = false; //标记是否获取成功
	wx.getLocation({
		success: function(res) {
			$.ajax({
				type: "post",
				contentType: "application/json", //必须有
				url: URL_all +'/api/amap/regeo',
				data: "{'location':'" + res.longitude + "," + res.latitude + "','radius':'1000','extensions':'all','batch':'false','roadlevel':'0'}",
				success: function(data) {
					console.log("获取位置成功：（" + res.longitude + "，" + res.latitude + "）")
					console.log(data);
					localStorage.address = data.dataResultObj.regeocode.addressComponent.city;
					localStorage.adcode = data.dataResultObj.regeocode.addressComponent.adcode;
					disLocation();
					callback && callback(); //只有在定位成功后才能执行的逻辑
				},
				error: function(xhr, type, errorThrown) {
					mui.toast("数据获取失败！");
				}
			});
			exist = true; //表示获取成功！
			console.log("获取位置成功：（" + res.longitude + "，" + res.latitude + "）");
		},
		fail: function(error) {
				if(!exist && (!localStorage.address && !localStorage.adcode)) { //(新获取的地理位置和地区码 或者 旧的地理位置或地区码)不存在就出现
					mui.toast("无法获取您的地理位置获取！");
				} else {
					disLocation();
				}
				console.log(error);
			}
			// complete:function(){
			//     if(!exist&&(!localStorage.address&&!localStorage.adcode)){//(新获取的地理位置和地区码 或者 旧的地理位置或地区码)不存在就出现
			//         mui.toast("无法获取您的地理位置获取！");
			//     }else{
			//         disLocation();
			//     }
			// }

	});

}

function disLocation() {
	var locationElem = document.getElementById('location') || document.getElementById("Location") || null;
	if(locationElem != null) {
		if(localStorage.adcode || localStorage.address) {
			locationElem.innerHTML = localStorage.address;
		} else {
			locationElem.innerHTML = '<span style="color:red">未知地理位置</span>';
		}
	}
}

function wxconfig(refresh, callback) {
	if(true) { //获取父页面的WX，这样可以成功调用微信接口
		wx = top.wx;
	}
	var tourl;
	tourl = document.URL;

	$.ajax({
		type: "post",
		contentType: "application/json", //必须有
		url: URL_all + '/api/wechat/jssdk/config',
		data: tourl,
		success: function(data) {
			console.log("SUCCESS" + data + "url:" + tourl);
			wx.config({
				debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
				appId: data.dataResultObj.appId, // 必填，企业号的唯一标识，此处填写企业号corpid
				timestamp: data.dataResultObj.timestamp, // 必填，生成签名的时间戳
				nonceStr: data.dataResultObj.nonceStr, // 必填，生成签名的随机串
				signature: data.dataResultObj.signature, // 必填，签名，见附录1
				jsApiList: ['getLocation',
						'checkJsApi',
						'onMenuShareTimeline',
						'onMenuShareAppMessage',
						'onMenuShareQQ',
						'onMenuShareWeibo',
						'onMenuShareQZone'
					] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
			});
			wx.ready(function() {
				if(refresh) { //直接重新定位
					submitOrderInfoClick(callback);
				} else {
					if(typeof localStorage.adcode == 'undefined' || typeof localStorage.address == 'undefined') {
						submitOrderInfoClick(callback);
					}
				}
			});

			// wx.error(function(res){
			//     mui.toast("error:微信配置出错("+res+")");
			// });

		},
		error: function(xhr, type, errorThrown) {
			//异常处理；
			console.log(type);
		}

	});
}

// window.addEventListener("load",function(){
//     wxconfig();
// })



function filteremoji(emojireg){
	//去掉微信名称里面的emoji 表情.以及空格
    var ranges = [
        '\ud83c[\udf00-\udfff]', 
        '\ud83d[\udc00-\ude4f]', 
        '\ud83d[\ude80-\udeff]',
        ' '
    ];
//  emojireg.replace(/(^\s*)|(\s*$)/g, ""); 
    return  emojireg.replace(new RegExp(ranges.join('|'), 'g'), '');
}

